# 父类
class Animal:
    def __init__(self, name):
        self.name = name

    # 实例方法
    def speek(self):
        print(self.name, "默认的叫声")


# Dog类继承 Animal 类
class Dog(Animal):
    # 重写父类方法
    def speek(self):
        print("小狗 %s 汪汪叫" % self.name)


# Cat类继承 Animal 类
class Cat(Animal):
    def speek(self):
        print("小猫", self.name, "喵喵叫")


class OtherClazz(object):
    def speek(self):
        print("不继承Animal类，且自身存在speek方法")


# 定义一个方法，需要传递一个参数
def speek(obj):
    obj.speek()

# 实例化对象
animal = Animal("animal")
cat = Cat("cat")
dog = Dog("dog")
other = OtherClazz()

# 调用speek方法
speek(animal)
speek(dog)
dog.speek()
speek(cat)
speek(other)
